import type { EditRoleUser, EmptyObject, Role, RoleData, RoleDetail, RoleParams, RoleUserData } from "@/types/system"
import { request } from "@/utils/reuqest"

export const getRoleListAPI =()=>{
  return request<Role[]>('/park/sys/role')
}

/**
 * 获取树形权限列表
 * @returns 
 */
export const getTreeListAPI = ()=>{
  return request<RoleData[]>('/park/sys/permision/all/tree');
}


/**
 * 获取角色详情
 * @param roleId 角色id
 * @returns 
 */
export const getRoleDetailAPI = (roleId: number)=>{
 return request<RoleDetail>(`/park/sys/role/${roleId}`)
}

export const getRoleUserAPI = (roleId:number)=>{
  return request<RoleUserData>(`/park/sys/roleUser/${roleId}`)
}

export const createRoleUserAPI = (data:RoleParams)=>{
  return request('/park/sys/role','POST',data)
}

export const EditRoleUserAPI = (roleId:string) =>{
  return request<EditRoleUser>(`/park/sys/role/${roleId}`,'GET')
}

export const UploadDataUserAPI = (data:EmptyObject) =>{
  return request('/park/sys/role','PUT',data)
} 

export const delRoleUserAPI = (roleId:number) =>{
  return request(`/park/sys/role/${roleId}`,'DELETE')
}

